<template>
  <div class="container_detail word-edit">
    <div class="header">
      <p>商品管理>查看第三方电子券>查看优惠券列表</p>
      <el-button @click="replaceLink" type="primary" size="mini">返回</el-button>
    </div>
    <div class="main">
      <el-table v-loading="loading" :data="thirdCouponDetailDTOs" :border='true'>
        <el-table-column  prop="sort" label="顺序"></el-table-column>
        <el-table-column  prop="url" label="链接"></el-table-column>
        <el-table-column  prop="couponPsw" label="兑换码"></el-table-column>
        <el-table-column  prop="validTime" label="有效期"></el-table-column>
        <el-table-column  prop="price" label="价格"></el-table-column>
        <el-table-column  prop="sort" label="是否已售">
            <template slot-scope="scope">
            {{scope.row.isSale == 'y'?'是':'否'}}
            </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
let CONSTANT = require("../../constant/constant.js");
let common = require("../../common.js");
let countryArr = require("../../../static/city.json");
export default {
  data() {
    return {
      id: "",
      info: "",
      // 返回 导航页码
      currentPage: 1,
      user: {},
      thirdCouponDetailDTOs:[],
      loading:true
    };
  },
  mounted() {
    this.id = this.$router.currentRoute.query.id;
    this.currentPage = this.$router.currentRoute.query.pageIndex;
    this.getDetail();
  },
  methods: {
    replaceLink(){
      this.$router.replace({
         path:'goodCheck',
         query:{
           id:this.id,
           pageIndex:this.currentPage
         }
       })
    },  
    returnName(val){
        let str;
        this.typeArr.map(item=>{
            if(item.value == val){
                str = item.name
            }
        })
        return str
    },
    getDetail() {
      let url = CONSTANT.URL.LIST.findEsGoodsById;
      let data = { id: this.id }
      common.requestAjax(url, JSON.stringify(data), null, res => {
          this.loading = false
        let data= res.data.bussData.esThirdCouponDetails;
         data.forEach((item,index)=>{
          item.sort = index+1
        })
        this.thirdCouponDetailDTOs = data
      });
    }
  }
};
</script>
<style lang="scss">
.word-edit {
  .el-form-item {
    margin: 0px;
    
  }

  .item-value {
    .el-input {
      width: 50%;
    }
    .el-select {
      width: 50%;
      .el-input {
        width: 100%;
      }
    }
  }
  .el-form-item__content {
    margin: 0px !important;
  }
}
</style>

